<?php
namespace app\api\controller\goods;
use think\App;
use app\api\common;
use app\api\ControllerBase;
use app\api\server\goods\GoodsOrder as GoodsOrderServer;
use think\exception\ValidateException;
/**
 * @title 商品订单
 */
class GoodsOrder extends ControllerBase{
	
    public function __construct(App $app){
        $this->REQUEST=$app->request;
        $this->checkParam($this->REQUEST);
        self::$s_server=new GoodsOrderServer($app);
    }
    
    /**
     * @title 创建商品订单
     * @param string data[0][goods_id] 48524688686579842 商品Id
     * @param string data[0][goods_details_id] 48524689965843184  对应商品详情id
     * @param string data[0][goods_price] 15 单价
     * @param string data[0][number] 5 购买数量
     * @param string data[1][goods_id] 49899055685304346 商品Id
     * @param string data[1][goods_details_id] 49899057056843776  对应商品详情id
     * @param string data[1][goods_price] 15 单价
     * @param string data[1][number] 5 购买数量
     * @param string addr_id  111 地址id
     * @param string total_money 150 总价
     */
    public function createGoodsOrder(){
    	$_param=$this->REQUEST->param();
		$checkFlag = $this->checkVailDate(\app\api\validate\Goods::class,__function__);
        if ($checkFlag == false) {
            return common::return_json($checkFlag, $this->ERROR, $this->CODE);
        }
        try {
            foreach ($_param['data'] as $k => $v) {
                $r = validate(\app\api\validate\Goods::class)->scene('createGoodsOrder_data')->check($v);
            }
        } catch (ValidateException $e) {
            $this->getMessageCode('adminMessage.field.error', 1);
            $this->ERROR = $this->ERROR . ',' . $e->getError();
            return common::return_json([], $this->ERROR, $this->CODE);
        }
        return $this->commonFunction(__function__);
    }
}
?>